<!DOCTYPE html>
<html>
<head>
<title>FridgeOre Mining Group</title>
<meta charset="utf-8">
<link href="../style.css" rel="stylesheet" type="text/css">
<?
// Connect to the Database
include_once "uconnect.php";

// Query for the Ore Names for the Drop Down Menus
$sql = "SELECT ore FROM ore ORDER by id";
$result = mysql_query($sql);
$oreNames = array(' ');
while ($row = mysql_fetch_array($result)) {
  $oreNames[] = $row['ore'];
}

// Generate the Select list Function
function generateSelect($name = '', $options = array()) {
    $html = '<select name="'.$name.'">';
    foreach ($options as $value => $option) {
        $html .= '<option value='.$value.'>'.$option.'</option>';
    }
    $html .= '</select>';
    return $html;
}

// POST Data Processing
if(isset($_POST['submit'])){
$pdquery = "SELECT * FROM ore WHERE '".$_POST['ore1']."' LIKE id";
$result = mysql_query($pdquery);
	$ore1data = array();
	while ($row = mysql_fetch_row($result)) {
	  $oredata1 = $row; }
}
else {}
?>
<body>
    <div id="wrapper">
        <div id="head">
        <div id="header">
            <p>FridgeOre Mining Group</p>
            <p><span id="copyrite">An Eve Online © Corporation</span></p>
        </div>
        </div>
        <div id="leftcolumnwrap">
        <div id="leftcolumn"><? include_once "../nav.php"; ?></div>
        </div>
        <div id="contentwrap">
        <div id="content">
        <p>
<?        
if(isset($_POST['submit'])){
	echo "<pre>";
	print_r($oredata1);
	echo "</pre>";
}
 else {}	
?>
</p>
      <form name="form1" method="POST" action="">
      <table align="center" border="1">
      <th colspan="3" bgcolor="dbdfe2">Buy Program Contract Calculator</th>
      <tr align="center">
      <th width="225">Select the Ore</th>
      <th width="150"># in Contract</th>
      <th width="150">Total Value</th>
      </tr> 
      <tr align="center">
        <td>
        <div align="center">
		<?
		if(isset($_POST['submit'])){
			$i = $oredata1[1];
			echo generateSelect('ore1', $oreNames); }
		else {
			echo generateSelect('ore1', $oreNames); 
			}
		 ?>
        </div>
        </td>
        <td><input type="text" size="15" maxlength="10" name="oreNum1" id="ore1"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore2', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum2" id="ore2"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore3', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum3" id="ore3"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore4', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum4" id="ore4"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore5', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum5" id="ore5"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore6', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum6" id="ore6"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore7', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum7" id="ore7"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore8', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum8" id="ore8"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore9', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum9" id="ore1"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore10', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum10" id="ore1"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td><div align="center"><? echo generateSelect('ore11', $oreNames); ?></div></td>
        <td><input type="text" size="15" maxlength="10" name="oreNum11" id="ore1"></td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <th colspan="2" align="center">Contract Total Value : </th>
        <th> $ <span>---</span></th>
      </tr>
      </table>
      <div align="center">
      <input type="submit" name="refresh" value="Start Over" onClick="../contractcalc.php">
      <input name="submit" type="submit" value="Submit">
      </div>
      </form>
        </div>
        </div>
        <div id="footerwrap">
        <div id="footer" align="center">
         <? include_once "../footer.php"; ?>
        </div>
        </div>
    </div>
</body>
</html>
